From 9d1dacfcc8f95720bc4b42d7ef0da33f0e6b665f Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sat, 7 Apr 2018 11:40:53 -0400 Subject: [PATCH] bin: Hide `admin instutil` command Add a "hidden command" flag, and use it for `admin instutil` since I regret adding it, and people should be using the API. Prep for adding another hidden command as part of staging deployments. (Down the line we should investigate deduplicating the recursive command parsing code) Closes: #1535 Approved by: jlebon --- src/ostree/ot-admin-builtin-instutil.c | 9 ++++++--- src/ostree/ot-builtin-admin.c | 13 ++++++++----- src/ostree/ot-builtin-remote.c | 10 ++++++---- src/ostree/ot-builtin-static-delta.c | 3 ++- src/ostree/ot-main.c | 9 ++++++--- src/ostree/ot-main.h | 3 ++- 6 files changed, 30 insertions(+), 17 deletions(-) diff --git a/src/ostree/ot-admin-builtin-instutil.c b/src/ostree/ot-admin-builtin-instutil.c index 035bd4f8..fe0d80a4 100644 --- a/src/ostree/ot-admin-builtin-instutil.c +++ b/src/ostree/ot-admin-builtin-instutil.c @@ -55,9 +55,12 @@ ostree_admin_instutil_option_context_new_with_commands (void) while (command->name != NULL) { - g_string_append_printf (summary, "\n %-24s", command->name); - if (command->description != NULL) - g_string_append_printf (summary, "%s", command->description); + if ((command->flags & OSTREE_BUILTIN_FLAG_HIDDEN) == 0) + { + g_string_append_printf (summary, "\n %-24s", command->name); + if (command->description != NULL) + g_string_append_printf (summary, "%s", command->description); + } command++; } diff --git a/src/ostree/ot-builtin-admin.c b/src/ostree/ot-builtin-admin.c index fd6d9a8f..1262c5a5 100644 --- a/src/ostree/ot-builtin-admin.c +++ b/src/ostree/ot-builtin-admin.c @@ -45,9 +45,9 @@ static OstreeCommand admin_subcommands[] = { { "init-fs", OSTREE_BUILTIN_FLAG_NO_REPO, ot_admin_builtin_init_fs, "Initialize a root filesystem" }, - { "instutil", OSTREE_BUILTIN_FLAG_NO_REPO, + { "instutil", OSTREE_BUILTIN_FLAG_NO_REPO | OSTREE_BUILTIN_FLAG_HIDDEN, ot_admin_builtin_instutil, - "Provide instutil commands, allow admin to change boot configuration and relabel selinux " }, + "Deprecated commands intended for installer programs" }, { "os-init", OSTREE_BUILTIN_FLAG_NO_REPO, ot_admin_builtin_os_init, "Initialize empty state for given operating system" }, @@ -85,9 +85,12 @@ ostree_admin_option_context_new_with_commands (void) while (command->name != NULL) { - g_string_append_printf (summary, "\n %-19s", command->name); - if (command->description != NULL) - g_string_append_printf (summary, "%s", command->description); + if ((command->flags & OSTREE_BUILTIN_FLAG_HIDDEN) == 0) + { + g_string_append_printf (summary, "\n %-19s", command->name); + if (command->description != NULL) + g_string_append_printf (summary, "%s", command->description); + } command++; } diff --git a/src/ostree/ot-builtin-remote.c b/src/ostree/ot-builtin-remote.c index 4deee8c6..0712d5bf 100644 --- a/src/ostree/ot-builtin-remote.c +++ b/src/ostree/ot-builtin-remote.c @@ -73,10 +73,12 @@ remote_option_context_new_with_commands (void) while (subcommand->name != NULL) { - g_string_append_printf (summary, "\n %-18s", subcommand->name); - if (subcommand->description != NULL) - g_string_append_printf (summary, "%s", subcommand->description); - + if ((subcommand->flags & OSTREE_BUILTIN_FLAG_HIDDEN) == 0) + { + g_string_append_printf (summary, "\n %-18s", subcommand->name); + if (subcommand->description != NULL) + g_string_append_printf (summary, "%s", subcommand->description); + } subcommand++; } diff --git a/src/ostree/ot-builtin-static-delta.c b/src/ostree/ot-builtin-static-delta.c index d2a343f2..4f9ff2b2 100644 --- a/src/ostree/ot-builtin-static-delta.c +++ b/src/ostree/ot-builtin-static-delta.c @@ -117,7 +117,8 @@ static_delta_usage (char **argv, while (command->name) { - print_func (" %-17s%s\n", command->name, command->description ?: ""); + if ((command->flags & OSTREE_BUILTIN_FLAG_HIDDEN) == 0) + print_func (" %-17s%s\n", command->name, command->description ?: ""); command++; } diff --git a/src/ostree/ot-main.c b/src/ostree/ot-main.c index 654a5f3d..237427a2 100644 --- a/src/ostree/ot-main.c +++ b/src/ostree/ot-main.c @@ -66,10 +66,13 @@ ostree_option_context_new_with_commands (OstreeCommand *commands) while (commands->name != NULL) { - g_string_append_printf (summary, "\n %-18s", commands->name); + if ((commands->flags & OSTREE_BUILTIN_FLAG_HIDDEN) == 0) + { + g_string_append_printf (summary, "\n %-18s", commands->name); - if (commands->description != NULL ) - g_string_append_printf (summary, "%s", commands->description); + if (commands->description != NULL ) + g_string_append_printf (summary, "%s", commands->description); + } commands++; } diff --git a/src/ostree/ot-main.h b/src/ostree/ot-main.h index ac75118c..b1b994b6 100644 --- a/src/ostree/ot-main.h +++ b/src/ostree/ot-main.h @@ -29,7 +29,8 @@ typedef enum { OSTREE_BUILTIN_FLAG_NONE = 0, OSTREE_BUILTIN_FLAG_NO_REPO = 1 << 0, - OSTREE_BUILTIN_FLAG_NO_CHECK = 1 << 1 + OSTREE_BUILTIN_FLAG_NO_CHECK = 1 << 1, + OSTREE_BUILTIN_FLAG_HIDDEN = 1 << 2, } OstreeBuiltinFlags; typedef enum { -- 2.30.2